package com.example.jetpacker

import android.view.View
import androidx.recyclerview.widget.LinearLayoutManager
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.chad.library.adapter.base.BaseQuickAdapter
import com.example.common.adapter.MenuAdapter
import com.example.common.base.AbsActivity
import com.example.common.model.MenuBean
import com.example.jetpacker.databinding.ActJetpackMenuBinding
import java.util.*

@Route(path = "/jetpack/menu")
class MenuActivity : AbsActivity<ActJetpackMenuBinding>() {

    override fun getLayoutId() = R.layout.act_jetpack_menu

    override fun main() {
        setTitle("JETPACK")
        initAdapter()
    }

    private fun initAdapter() {
        val data: MutableList<MenuBean> = ArrayList()
        data.add(MenuBean("viewModel", 0))
        data.add(MenuBean("lifecycle", 0))
        data.add(MenuBean("livedata", 0))
        val adapter = MenuAdapter(data)
        adapter.setOnItemClickListener { adapter1: BaseQuickAdapter<*, *>?, view: View?, position: Int ->
            when (position) {
                0 -> {
                    ARouter.getInstance().build("/jetpack/viewModel/one").navigation()
                }
                1 -> ARouter.getInstance().build("/jetpack/lifecycles/one").navigation()
                2 -> ARouter.getInstance().build("/jetpack/livedata").navigation()
            }
        }
        mBinding.rv.layoutManager = LinearLayoutManager(this)
        mBinding.rv.adapter = adapter
    }

    override fun initListener() {

    }

}